package com.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeDao extends BaseMapper<Employee> {
    @Select("select * from employee where username=#{username}")
    public Employee selectemployeebyusername(String username);
    @Insert("insert into employee (name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    public void saveemployee(Employee employee);

    @Select("select * from employee limit #{pagecount},#{pageSize}")
    public List<Employee> selectallbypage(int pagecount,int pageSize);

    @Select("select count(*) from employee")
    public long selectcount();

    @Select("select * from employee where name=#{name} limit #{pagecount},#{pageSize}")
    public List<Employee> selectbypageandname(int pagecount,int pageSize,String name);

    @Update("update employee set status=#{status},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    public void updatestatusbyid(Employee employee);

    @Select("select * from employee where id=#{id}")
    public  Employee selectemployeebyid(Long id);
    @Update("update employee set name=#{name},username=#{username},phone=#{phone},sex=#{sex},id_number=#{idNumber},create_time=#{createTime},update_user=#{updateUser} where id=#{id}")
    public void updateemployee(Employee employee);
}
